package com.kangyi.user.mapper;

import com.github.pagehelper.Page;
import com.kangyi.dto.ApplicationListDTO;
import com.kangyi.entity.NursingHomeApplication;
import com.kangyi.enumeration.OperationType;
import com.kangyi.user.annotation.AutoFill;
import com.kangyi.vo.ApplicationListVO;
import com.kangyi.vo.NursingHomeApplicationDetailVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

/**
 * @author Blank
 * @version 1.0
 */
@Mapper
public interface NursingHomeApplicationMapper {

    @Insert("insert into nursing_home_application(nursing_home_name, organization_id, user_id, director, establishment_time, id_card, phone, address_description, business_license, establishment_license, fire_safety_certificate, real_estate_certificate_or_lease_certificate, hygienic_license, rejection_reason, create_user, update_user,create_time,update_time)" +
            "values(#{nursingHomeName},#{organizationId},#{userId},#{director},#{establishmentTime},#{idCard},#{phone},#{addressDescription},#{businessLicense},#{establishmentLicense},#{fireSafetyCertificate},#{realEstateCertificateOrLeaseCertificate},#{hygienicLicense},#{rejectionReason},#{createUser},#{updateUser},#{createTime},#{updateTime}) ")
    @AutoFill(value = OperationType.INSERT)
    void submit(NursingHomeApplication nursingHomeApplication);

    List<ApplicationListVO> listApplication(ApplicationListDTO applicationListDTO);

    @Select("select count(*) from nursing_home_application where user_id = #{userId};")
    Long countTotalByUserId(Integer userId);

    @Delete("delete from nursing_home_application where id = #{applicationId};")
    void deleteById(Integer applicationId);

    @Select("select * from nursing_home_application where id = #{applicationId};")
    NursingHomeApplication selectById(Integer applicationId);

    NursingHomeApplicationDetailVO DetailApplication(Integer applicationId);
}
